# -*- coding:utf-8 -*-
from pydantic import Field, BaseModel
from typing import List
from sqlalchemy import Column, Integer, String, DateTime, Enum, DECIMAL, Float, TEXT
from core.curd import Base, TimestampMixin


class SysRole(Base, TimestampMixin):
    """
    测试表
    """
    __tablename__ = 'sys_role'

    id = Column(Integer, nullable=False, autoincrement=True, primary_key=True, comment='id')
    name = Column(String(50), comment='角色名称')
    role_code = Column(String(50), comment='角色编码')
    data_scope = Column(Integer,
                        comment='数据范围  0：全部数据  1：本机构及子机构数据  2：本机构数据  3：本人数据  4：自定义数据')
    org_id = Column(Integer, comment='机构ID')
    version = Column(Integer, comment='版本号')
    deleted = Column(Integer, comment='删除标识  0：正常   1：已删除')
    creator = Column(Integer, comment='创建者')
    updater = Column(Integer, comment='更新者')
    status = Column(Integer, comment='状态  0：停用   1：正常')


class SysRoleMenu(Base, TimestampMixin):
    __tablename__ = 'sys_role_menu'

    id = Column(Integer, nullable=False, autoincrement=True, primary_key=True, comment='id')
    role_id: int = Field(comment='role_id')
    menu_id: int = Field(comment='menu_id')
    version = Column(Integer, comment='版本号')
    deleted = Column(Integer, comment='删除标识  0：正常   1：已删除')
    creator = Column(Integer, comment='创建者')
    updater = Column(Integer, comment='更新者')


class SysRoleDataScope(Base):
    """
    测试表
    """
    __tablename__ = 'sys_role_data_scope'

    id = Column(Integer, nullable=False, autoincrement=True, primary_key=True, comment='id')
    role_id = Column(Integer, comment='角色ID')
    org_id = Column(Integer, comment='机构ID')


class CreateSysRole(BaseModel):
    name: str = Field(comment='角色名称', max_length=50)
    role_code: str = Field(comment='角色编码', max_length=50)
    remark: str = Field(comment='备注', max_length=100)
    menuIdList: List[int] = Field(comment='关联菜单项')
    status: int = Field(comment="状态 0 停用 1正常")


class UpdateSysRole(BaseModel):
    id: int = Field(comment='id')
    name: str = Field(comment='角色名称', max_length=50)
    role_code: str = Field(comment='角色编码', max_length=50)
    remark: str = Field(comment='备注', max_length=100)
    menuIdList: List[int] = Field(comment='关联菜单项')
    status: int = Field(comment="状态 0 停用 1正常")


class UpdateSysRoleDataScope(BaseModel):
    id: int = Field(comment='id')
    data_scope: int = Field(comment='权限编码')
    orgIdList: List[int] = Field(comment='关联部门')
